home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 30 / Amiga Format AFCD30 (Sep 1998, Issue 114).iso / s / afcdfind-handlematch.dopus5 next >
Text File  |  1998-06-26  |  3KB  |  119 lines

  1. /* $VER: AFCDFind-HandleMatch.dopus5 1.1 (25.6.98)
  2. **
  3. ** Support script used by AFCDFind
  4. **
  5. ** Usage: OpenLister.dopus5 pathname
  6. ** Looks in ENV:AFCDFind_DOpus for config options
  7. **
  8. ** Author: Oliver Roberts
  9. ** E-Mail: oliver.roberts@iname.com
  10. **    WWW: http://www.nanunanu.org/~oliver/
  11. */
  12.  
  13. options results
  14. options failat 21
  15.  
  16. /* DOpus running? */
  17.  
  18. If ~Show("P","DOPUS.1") Then Do
  19.    EXIT
  20. End
  21.  
  22. Address "DOPUS.1"
  23.  
  24. /* Check version and exit if older than v5.5 */
  25.  
  26. dopus version
  27. If ( result='RESULT' | translate(result,'.',' ') < 5.1218 ) then do
  28.    dopus request '"This script requires DOpus v5.5 or greater." OK'
  29.    EXIT
  30. end
  31.  
  32. /* Parse in arguments and options in environment variable */
  33.  
  34. parse arg pathname
  35.  
  36. CALL GetEnv('AFCDFind_DOpus')
  37. config = RESULT
  38.  
  39. parse var config . listermode
  40.  
  41. /* Turn AmigaDOS 'Insert Volume' requesters off */
  42.  
  43. pragma('W','N')
  44.  
  45. /* Determine if the correct CD is inserted, and if not, ask the user to
  46.    insert it */
  47.  
  48. volume = left(pathname,pos(':',pathname))
  49. DO UNTIL (correctcd = 0 | exists(volume))
  50.   correctcd = 1;
  51.   If ~Exists(volume) Then Do
  52.       msg = "Please insert Amiga Format CD " || substr(volume,5,length(volume)-5)
  53.       dopus request '"'msg'" OK|Cancel'
  54.       correctcd = RC
  55.   end
  56. end
  57.  
  58. /* Do the action if requested CD is available */
  59.  
  60. if (correctcd = 1 & exists(volume)) then do
  61.    stat = statef(pathname)
  62.    if (WORD(stat,1) = 'DIR') then do
  63.       /* Drawer button: Open the lister */
  64.       /* If drawer has no icon, make sure we are in showall mode */
  65.       drawericon = pathname
  66.       if (right(drawericon,1) = '/') then drawericon = left(drawericon,length(drawericon)-1)
  67.       drawericon = drawericon || '.info'
  68.       if (~exists(drawericon)) then do
  69.          if (~find(listermode,'showall')) then listermode = listermode 'showall'
  70.       end
  71.  
  72.       dopus version
  73.       if (translate(result,'.',' ') < 5.8) then do
  74.          /* Open the lister the messy way - workaround for bug in DOpus */
  75.          lister new pathname
  76.          ourlister = RESULT
  77.          if (word(listermode,1) ~= 'name') then do
  78.             lister set ourlister mode listermode
  79.          end
  80.       end
  81.       else do
  82.          /* Open the list the clean way with DOpus 5.8 or higher */
  83.          lister new invisible pathname
  84.          ourlister = RESULT
  85.          lister set ourlister mode listermode
  86.          lister read ourlister pathname
  87.          lister set ourlister visible on
  88.       end
  89.    end
  90.    else do
  91.       /* File button: get DOpus to act on file according to filetypes */
  92.       command doubleclick pathname
  93.    end
  94. end
  95.  
  96. /* Finished */
  97.  
  98. EXIT
  99.  
  100. /* Procedure definitions */
  101.  
  102. /* GetEnv()  return the value of an environmental variable           */
  103. GetEnv: procedure
  104.    /* Arguments:                                                     **
  105.    **   arg(1) := The name of the variable to retrieve               **
  106.    ** Returns     a string                                           */
  107.    /* Use function from rexxarplib if it's available                 */
  108. if show('L', 'rexxarplib.library') then
  109.    return 'GetEnv'(arg(1))
  110.  
  111.    /*  OPEN()  will fail if variable is not defined. Null will be    **
  112.    ** returned in that case                                          */
  113. if open(6Env, 'env:'arg(1), 'R') then do
  114.    EnvVar = readln(6Env)
  115.    call close 6Env
  116. end
  117. else EnvVar = ''
  118. return EnvVar
  119.